﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.facebook.delegates {
    import flash.events.*;
    import flash.utils.*;
    import com.facebook.net.*;
    import flash.net.*;
    import com.facebook.session.*;
    import com.facebook.utils.*;

    public class AbstractFileUploadDelegate extends WebDelegate {

        protected var ba:ByteArray;

        public function AbstractFileUploadDelegate(_arg1:FacebookCall, _arg2:WebSession){
            super(_arg1, _arg2);
            this.ba = new ByteArray();
        }
        protected function uploadByteArray(_arg1:ByteArray):void{
            var _local3:String;
            var _local4:URLRequest;
            var _local2:PostRequest = new PostRequest();
            for (_local3 in call.args) {
                if (_local3 != "data"){
                    _local2.writePostData(_local3, call.args[_local3]);
                };
            };
            _local2.writeFileData(((("fn" + call.args["call_id"]) + ".") + this.getExt()), _arg1, this.getContentType());
            _local2.close();
            _local4 = new URLRequest();
            _local4.method = URLRequestMethod.POST;
            _local4.contentType = ("multipart/form-data; boundary=" + _local2.boundary);
            _local4.data = _local2.getPostData();
            _local4.url = _session.rest_url;
            createURLLoader();
            loader.dataFormat = URLLoaderDataFormat.BINARY;
            loader.load(_local4);
        }
        protected function onFileRefComplete(_arg1:Event):void{
            fileRef = (call.args.data as FileReference);
            this.uploadByteArray(fileRef["data"]);
        }
        override protected function onDataComplete(_arg1:Event):void{
            var _local3:String;
            var _local2:ByteArray = (_arg1.target.data as ByteArray);
            if (_local2 == null){
                super.onDataComplete(_arg1);
            } else {
                _local3 = _local2.readUTFBytes(_local2.length);
                _local2.length = 0;
                _local2 = null;
                handleResult(_local3);
            };
        }
        protected function getExt():String{
            return (null);
        }
        protected function getContentType():String{
            return (null);
        }

    }
}//package com.facebook.delegates 
